#include "ShiftRegister.h"

//Shift Register acts like a really weird Node
//preprocess: the source value is created
//and the loop entry terminal is added to the source value
//and the source is propagated
//process: When it's processed it adds the sink value to it's phi node
//and copies it's value to the loop exit terminal


ShiftRegister::ShiftRegister(DoWhile* parent,
			     SourceTerminal* entryTerminal,
			     SourceTerminal* exitTerminal,
			     std::string name) : Node(parent), name(name) {
  addSink();
  addSource();
  this->entryTerminal=entryTerminal;
  this->exitTerminal=exitTerminal;
}

void ShiftRegister::preprocess(llvm::IRBuilder<> *builder) {
  llvm::BasicBlock* currentBlock = builder->GetInsertBlock();
  llvm::PHINode* phi = builder->CreatePHI(llvm::Type::getInt32Ty(llvm::getGlobalContext()), 2, name);
  llvm::
}

void ShiftRegister::process(llvm::IRBuilder<> *builder) {
  
  (llvm::PHINode*) terminals[1]->getValue();
  phi->addIncoming(terminals[0]->getValue(),currentBlock);
}
